package com.lingyuan.ums.controller;

import com.lingyuan.common.core.domain.R;
import com.lingyuan.common.core.domain.vo.ums.MemberAddressVo;
import com.lingyuan.common.core.exception.ServiceException;
import com.lingyuan.ums.domain.MemberAddressEntity;
import com.lingyuan.ums.service.MemberAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName：MemberAddressContrller
 * @Author: LeiHao
 * @Date: 2024/9/21 11:53
 * @Description: 会员收货地址控制层
 */
@RestController
@RequestMapping("memberAddress")
public class MemberAddressController {

    @Autowired
    private MemberAddressService memberAddressService;

    /* *
     * @Title: findMemberByIdAddressList
     * @Author: DELL
     * @Date: 2024-09-21 12:06:43
     * @Params: [userId]
     * @Return: R<List<MemberAddressVo>>
     * @Description: 根据用户id查询会员收货地址
     */
    @GetMapping("findMemberByIdAddressList/{userId}")
    public R<List<MemberAddressVo>> findMemberByIdAddressList(@PathVariable Long userId){
        if (userId == null||userId<=0){
            throw new ServiceException("参数错误");
        }
        List<MemberAddressVo> memberAddressEntityList = memberAddressService.findMemberByIdAddressList(userId);
        return R.ok(memberAddressEntityList,"查询成功");
    }

    /* *
     * @Title: findById
     * @Author: DELL
     * @Date: 2024-09-21 12:06:56
     * @Params: [id]
     * @Return: R<MemberAddressVo>
     * @Description: 根据id查询会员收货地址
     */
    @GetMapping("findById/{id}")
    public R<MemberAddressVo> findById(@PathVariable Long id){
        if (id == null||id<=0){
            throw new ServiceException("参数错误");
        }
        MemberAddressVo memberAddressEntity = memberAddressService.findById(id);
        return R.ok(memberAddressEntity,"查询成功");
    }

}
